<?php 

/**
* 
*/
class Code
{	
	public $width;
	public $height;
	public $lenght;
	public $dian;
	public $xian;
		
	public $src;
	public function show($width=250,$height=120,$lenght=5,$dian=1000,$xian=20)
	{
		$this->width=$width;
		$this->height=$height;
		$this->lenght=$lenght;
		$this->dian=$dian;
		$this->xian=$xian;
		$this->_createImg();
		$this->_shuzi();
		$this->_point();
		$this->_line();
		$this->_outPut();
	}

	public function _createImg()
	{
		header("Content-type: image/jpeg");
		$this->src = imageCreateTrueColor($this->width,$this->height);
		$color = imageColorAllocate($this->src,255,255,255);
		imageFill($this->src,0,0,$color);
		$color = imageColorAllocate($this->src,mt_rand(0,255),mt_rand(0,255),mt_rand(0,250));
	}
// 
	public function _shuzi()
	{
		for ($i=0; $i < $this->lenght; $i++) { 
		$str = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890";
		$code = $str[mt_rand(0,strlen($str)-1)];

		$width=$i*45;
		$width+=12;

		$height=mt_rand(80,105);

		$color = imageColorAllocate($this->src,mt_rand(0,255),mt_rand(0,255),mt_rand(0,250));

		imagettftext ($this->src, mt_rand(55,75) , mt_rand(-10,15) ,$width ,$height,$color, './FireBlock.ttf' , $code);

		}
	}

	public function _point()
	{
		for ($i=0; $i < $this->dian; $i++) { 
	$color = imageColorAllocate($this->src,mt_rand(0,250),mt_rand(0,250),mt_rand(0,250));
	imagesetpixel ( $this->src , mt_rand(0,250) , mt_rand(0,125), $color);
		}
	}

	public function _line()
	{
		for ($i=0; $i < $this->xian; $i++) { 
	$color = imageColorAllocate($this->src,mt_rand(0,250),mt_rand(0,250),mt_rand(0,250));

	imageline ( $this->src , mt_rand(0,250) , mt_rand(0,60) , mt_rand(0,250) , mt_rand(60,125), $color);
		}
	}

	public function _outPut()
	{
		imagejpeg($this->src);
	}









}










 ?>